﻿EXECUTE ReadDataFromDB_ViewStructure_Updating '(Person AS Father,FATHER AS FA,Person AS Child)',
				'Father.FullName,Child.FullName',NULL

EXECUTE ReadDataFromDB_ViewStructure_Updating 'CourseDIV',
				'CourseName',NULL

EXECUTE ReadDataFromDB_ViewStructure_Updating '(Person AS Father,FATHER AS FA,Person AS Child)(Person AS Mother,MOTHER AS MA,Person AS Child)',
				'Father.FullName,FA.RelationshipName,Mother.FullName,MA.RelationshipName,Child.FullName',NULL

EXECUTE ReadDataFromDB_ViewStructure_Updating '(Person AS Parent,FATHER AS PA,Person AS Child) OR (Person AS Parent,MOTHER AS PA,Person AS Child)',
				'Parent.FullName,PA.RelationshipName,Child.FullName',NULL

EXECUTE ReadDataFromDB 'Parents'

SELECT * FROM DefinedViews

-- Routines for clearing the system and re-inserting conversion data
--delete from UndoAttributes
--delete from UndoEntityRelationships
--delete from UndoOtherChanges
--delete from UndoDayTimeDIV
--delete from attributes
--delete from entityrelationships
--delete from entities where entityID <> 0

--SET IDENTITY_INSERT entities ON
--INSERT INTO entities(EntityID,EntitySubType,EntityType)
--VALUES (10000,'School','SchoolDiv');
--INSERT INTO Attributes(EntityID,AttributeID,AttributeValueString)
--VALUES (10000,1013,'Rift Valley Academy')
--INSERT INTO EntityRelationships(ShortRelationshipName,Entity1ID,Entity2ID)
--VALUES ('SCHDIV',0,10000)
--SET IDENTITY_INSERT entities OFF
--DBCC CHECKIDENT ('Entities', RESEED, 10200)
--GO



select * from attributes where attributevaluestring = '11111'
select * from entities where entityid = 10656

select * From mboa.coredata.dbo.persons
select * From mboa.coredata.dbo.current_students

SELECT        dbo.Persons.PersonID, dbo.Persons.OldRVAID, dbo.Persons.OldIsStudent, dbo.Persons.Lname, dbo.Persons.Fname, dbo.Persons.Mname, dbo.Persons.Pname, dbo.Persons.Bdate, dbo.Persons.Gender, 
                         dbo.Persons.Gradyear, dbo.Persons.Logon, dbo.Persons.Account_Number, dbo.Persons.MaidenName, dbo.Persons.Birth_Country, dbo.Persons.Citizenship1, dbo.Persons.Citizenship2, dbo.Persons.Nationality1,
                          dbo.Persons.Nationality2, dbo.Persons.SS_Number, dbo.Persons.IsLiving, dbo.Persons.Title
FROM            dbo.Persons INNER JOIN
                         dbo.Enrollment ON dbo.Persons.PersonID = dbo.Enrollment.PersonID INNER JOIN
                         dbo.Current_YearTerm ON dbo.Enrollment.Enrollment_Year = dbo.Current_YearTerm.School_Year AND dbo.Enrollment.Enrollment_Term = dbo.Current_YearTerm.School_Term
WHERE        (dbo.Enrollment.Enrollment_Type = 'Student')


SELECT *
FROM coredata.dbo.Current_Parents P
	INNER JOIN coredata.dbo.Email_Addresses EA ON P.PersonID = EA.PersonID
	INNER JOIN coredata.dbo.Email_Usage EU ON EA.EmailID = EU.EmailID
WHERE EU.Usage = 'Logon'